package cn.gdcp.service;

import android.os.Binder;

import java.text.SimpleDateFormat;
import java.util.Date;

public class MyBinder extends Binder{
    //计算两个数的和
    public int add(int a,int b){
        return a+b;
    }
    //转换大写字母
    public String toUpperCase(String str){
        return str.toUpperCase();
    }
    //获取当前时间
    public String getTimeStr() {
        Date date=new Date();
        SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        return format.format(date);
    }
    //字符串单词逆序 先拆分后反转
    public String strRereverse(String str){
        String[] arr=str.split(" ");
        StringBuffer buffer=new StringBuffer();
        for(int i=0;i<arr.length;i++){
            buffer.append(reverse(arr[i])).append(" ");
        }
        return buffer.toString();
    }
    private static String reverse(String str) {
        char[] charr = str.toCharArray();
        int len = charr.length;
        for (int i = 0; i < len / 2; i++) {
            char ch = charr[i];
            charr[i] = charr[len - 1 - i];
            charr[len - 1 - i] = ch;
        }
        return new String(charr);
    }
}
